<div class="contentcontainer">
    <div class="headings altheading">
        <h2>菜单列表</h2>
    </div>
    <div class="contentbox" data-uri='{:U("Admin/RoleNav/doEditStatus")}'>
        <table width="100%" class="list td_align">
            <thead>
                <tr class="even">
                    <td class="field_head"><input name="u_id" type="checkbox" id="checkboxall" /></td>
                    <td class="field_head">操作</td>
                    <td class="field_head">菜单名称</td>
                    <td class="field_head">菜单排序</td>
                    <td class="field_head">状态</td>
                </tr>
            </thead>
            <tbody>
            <volist name="data" id="vo">
                <tr id="list_{$vo.id}">
                    <td class="center"><input type="checkbox" value="{$vo.id}" name="checkall" class="checkSon" /></td>
                    <td class="center">
                        <a href='{:U("Admin/RoleNav/editRoleNav","id=$vo[id]")}' title="编辑"><img src="__PUBLIC__/Admin/images/icons/icon_edit.png" alt="编辑" title="编辑" /></a>
                        <a href="javascript:void(0);" title="删除" class="dodel" val="{$vo.id}" data-uri='{:U("Admin/RoleNav/doDelete","id=$vo[id]")}' data-acttype="ajax"><img src="__PUBLIC__/Admin/images/icons/icon_square_close.png" alt="删除" title="删除" /></a>
                    </td>
                    <td class="center">{$vo.name}</td>
                    <td class="center">{$vo.sort}</td>
                    <td class="center">
                            <img class="pointer" data-id="{$vo[id]}" style="cursor: pointer;" data-field="status" data-value="{$vo.status}"
                                <if condition="$vo.status eq '1'">
                                    src="__PUBLIC__/Admin/images/icons/icon_1.png" alt="启用" title="启用"
                                <else />
                                    src="__PUBLIC__/Admin/images/icons/icon_0.png" alt="停用" title="停用"
                                </if> 
                            />
                        </if>
                    </td>
                </tr>
            </volist>
            <empty name="data">
                <tr><td colspan="5" class="left">暂时没有数据!</td></tr>
            </empty>
            </tbody>
        </table>
        <ul class="pagination">
            {$page}
            <select name="pageall" onChange="window.location.href=this.value">
                <option value='{:U("Admin/RoleNav/pageList","pageall=1")}' <if condition="$filter.pageall eq '1'">selected="selected"</if>>1条/页</option>
                <option value='{:U("Admin/RoleNav/pageList","pageall=5")}' <if condition="$filter.pageall eq '5'">selected="selected"</if>>5条/页</option>
                <option value='{:U("Admin/RoleNav/pageList","pageall=10")}'<if condition="$filter.pageall eq '10'">selected="selected"</if>>10条/页</option>
                <option value='{:U("Admin/RoleNav/pageList","pageall=20")}'<if condition="$filter.pageall eq '20'">selected="selected"</if>>20条/页</option>
                <option value='{:U("Admin/RoleNav/pageList","pageall=50")}'<if condition="$filter.pageall eq '50'">selected="selected"</if>>50条/页</option>
                <option value='{:U("Admin/RoleNav/pageList","pageall=80")}'<if condition="$filter.pageall eq '80'">selected="selected"</if>>80条/页</option>
                <option value='{:U("Admin/RoleNav/pageList","pageall=100")}'<if condition="$filter.pageall eq '100'">selected="selected"</if>>100条/页</option>
                <option value='{:U("Admin/RoleNav/pageList","pageall=500")}'<if condition="$filter.pageall eq '500'">selected="selected"</if>>500条/页</option>
            </select>
        </ul>

        <div style="clear: both;"></div>
    </div>

</div>
<script>
    $(document).ready(function(){
        $(".dodel").click(function(){
            var val = $(this).attr("val");
            var self = $(this),
            url = self.attr('data-uri');
            if(confirm("确定删除管理员？")){
                $.ajax({
                    url:url,
                    cache:false,
                    dataType:"json",
                    data: {},
                    type:"POST",
                    beforeSend:function(){
                        $("#J_ajax_loading").stop().removeClass('ajax_error').addClass('ajax_loading').html("提交请求中，请稍候...").show();
                    },
                    error:function(){
                        $("#J_ajax_loading").removeClass('ajax_success').addClass('ajax_error').html("AJAX请求发生错误！").show().fadeOut(5000);
                    },
                    success:function(msgObj){
                        $("#J_ajax_loading").hide();
                        if(msgObj.status == '1'){
                            $("#list_"+val).remove();
                            $("#J_ajax_loading").removeClass('ajax_error').addClass('ajax_success').html(msgObj.info).show().fadeOut(5000);
                        }else{
                            $("#J_ajax_loading").removeClass('ajax_success').addClass('ajax_error').html(msgObj.info).show().fadeOut(5000);
                        }
                    }
                });
            }
        });
    
        //切换
        $('.pointer').live('click', function() {
            var url = $(".contentbox").attr("data-uri");
            var img    = this,
            s_val  = ($(img).attr('data-value'))== 0 ? 1 : 0,
            s_name = $(img).attr('data-field'),
            s_id   = $(img).attr('data-id'),
            s_src  = $(img).attr('src');
            s_msg = ($(img).attr('data-value'))== 0 ? '启用' : '停用';
            $.ajax({
                url:url,
                cache:false,
                dataType:"json",
                data: {id:s_id, field:s_name, val:s_val},
                type:"POST",
                beforeSend:function(){
                    $("#J_ajax_loading").stop().removeClass('ajax_error').addClass('ajax_loading').html("提交请求中，请稍候...").show();
                },
                error:function(){
                    $("#J_ajax_loading").addClass('ajax_error').html("AJAX请求发生错误！").show().fadeOut(5000);
                },
                success:function(msgObj){
                    $("#J_ajax_loading").hide();
                    if(msgObj.status == '1'){
                        $("#J_ajax_loading").removeClass('ajax_error').addClass('ajax_success').html(msgObj.info).show().fadeOut(5000);
                        if(s_src.indexOf('0')>-1) {
                                $(img).attr({'src':s_src.replace('0','1'),'data-value':s_val,'title':s_msg,'alt':s_msg});
                        } else {
                                $(img).attr({'src':s_src.replace('1','0'),'data-value':s_val,'title':s_msg,'alt':s_msg});
                        }
                    }else{
                        $("#J_ajax_loading").removeClass('ajax_success').addClass('ajax_error').html(msgObj.info).show().fadeOut(5000);
                    }
                }
            });
        });
    });    
</script>